import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class Unija {

	public static class Interval {
		public Interval(int a, int b) {
			this.a = a;
			this.b = b;
		}
		public int a; // donja granica intervala
		public int b; // gornja granica intervala
	}
	
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

		int N = Integer.parseInt(in.readLine());

		List<Interval> lista = new ArrayList<Interval>(N);

		for(int i=0; i<N; i++) {
			String p[] = in.readLine().split(" ");
			lista.add(new Interval(Integer.parseInt(p[0]),Integer.parseInt(p[1])));
		}

		// Sortiranje po donjoj granici intervala
		Collections.sort(lista, new Comparator<Interval>() {
			public int compare(Interval o1, Interval o2) {
				return o1.a - o2.a;
			}
		});
		int br = lista.get(0).b - lista.get(0).a + 1;
		int top = lista.get(0).b;
		for(int i=1; i<N; i++) {
			Interval x = lista.get(i);
			if(x.b<=top) {
				continue;
			} else {
				if(x.a>top) {
					br+=x.b-x.a+1;
				} else {
					br+= x.b - top;
				}
				top=x.b;
			}	
		}

		System.out.print(br);
	}
}
